require(["config"],function(){
	//引入依赖模块
	require(["jquery","header"],function($){
		function Login(){
			this.addListener();
		}
		
		$.extend(Login.prototype,{
			addListener : function(){
				console.log("登录成功1");
				$("#login-btn").on("click" , $.proxy(this.loginHandler, this));
			},
			
			//登录
			loginHandler : function(){
				var data = $(".form-input").serialize();
				
				var url ="http://localhost:80/bastcake-pc-project/api/login.php";
				
				$.post(url, data, this.regSuccessHandler, "json");
				return false;
			},
			
			regSuccessHandler:function(data){
				if (data.res_code === 1) { //登录成功
					console.log("登录成功");
					location = "/index.html";
				} else { // 登录失败
					alert("用户名或密码错误");
				}
			}
		});
		new Login();
	});
});
